# -*- encoding=utf8 -*-
"""
RedFlag-TC000027    配乐功能检查
检查配乐功能
1.新增配乐
2.更多配乐
3.删除配乐
"""
__author__ = "ldm"

import sys
import os
# 获取当前脚本所在目录.py
current_dir = os.path.dirname(os.path.abspath(__file__))
# 获取上级目录.air
parent_dir = os.path.dirname(current_dir)
# 获取上级目录air
grandparent_dir = os.path.dirname(parent_dir)
# 获取和air目录平级的conf、testcase目录路径
conf_dir = os.path.join(grandparent_dir, 'conf')
testcase_dir = os.path.join(grandparent_dir, 'testcase')
# 将conf、testcase目录添加到sys.path
sys.path.append(conf_dir)
sys.path.append(testcase_dir)

from PageFunction import CameraVideoShooter
from elements import *
auto_setup(__file__)

shooter = CameraVideoShooter()

log("----------------------------新增配乐-------------------------------")
"""
点击相机拍摄
点击添加配乐
选择选中歌曲一
获取断言文本
断言
"""
shooter.enter_photograph()
shooter.click_element(shooting_page_Music_button)
shooter.click_element(shooting_page_Song_one)
music_text = shooter.get_element_text(poco("cn.migu.video.clip.walle:id/clip_rc_music_name_tv"))
shooter.assert_texts_equal(music_text, "一定要爱你—魏新雨", "断言失败，预期文案与实际文案不符合")

log("----------------------------更多配乐-------------------------------")
"""
点击添加配乐按钮
点击更多配乐
选择选中歌曲二
获取断言文本
断言
"""

shooter.click_element(shooting_page_Music_button)
shooter.click_element(shooting_page_More_music_tracks)
shooter.click_element(shooting_page_Song_two)
music_text = shooter.get_element_text(poco("cn.migu.video.clip.walle:id/clip_rc_music_name_tv"))
shooter.assert_texts_equal(music_text, "我在人民广场吃炸鸡-你猜我是谁", "断言失败，预期文案与实际文案不符合")

log("----------------------------删除配乐-------------------------------")
"""
点击删除图标
出现的二次确认弹窗选择是
获取配乐工具栏文案
断言
"""

shooter.click_element(shooting_page_Music_button)
shooter.click_element(shooting_page_delete_music)
shooter.click_element(shooting_page_confirm_delete)
music_text1 = shooter.get_element_text(music_columnpoco_elenment, 0, "cn.migu.video.clip.walle:id/walle_ugc_clip_empty_recommend_tv")
shooter.assert_texts_equal(music_text1, "当前无配乐，快去挑选一个吧~", "断言失败，预期文案与实际文案不符合")

# 关闭应用
stop_app(UGC_package_name)